/****************************************************************************
**
** This file is part of qPhotoTag, a photo keywording application
**
** Copyright (C) 2009 Marcell Lengyel <miketkf@gmail.com>
**
** GNU General Public License
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**
****************************************************************************/

#ifndef MAINWINDOWIMPL_H
#define MAINWINDOWIMPL_H
/*! \file mainwindowimpl.h
    \brief This file contains the declaration of the qPhotoTag application main window class
 */
#include <QMainWindow>
#include "taglist.h"
#include "photoview.h"
#include "captionedit.h"
#include "preferencesdialog.h"
//
QT_BEGIN_NAMESPACE
class QAction;
class QMenu;
class QPlainTextEdit;
class QGroupBox;
class QVBoxLayout;
class QHBoxLayout;
class QListView;
class QPushButton;
class QLineEdit;
class QStandardItemModel;
class QCheckBox;
class QComboBox;
class QSpinBox;
class QDoubleSpinBox;
QT_END_NAMESPACE

#define QTAG_VERSION "0.1.3"

//! The main window for the qPhotoTag application
/*!
  It is a QMainWindow subclass, has a photo thumbnail view and different
  kind of editors for manipulating the IPTC keywords and captions for the
  photos.
 */
class MainWindowImpl : public QMainWindow
{
Q_OBJECT
public:
    //! Constructor
    /*!
      It sets the default window size and call the methods to initialize
      the UI. It also reads saved settings.

      \sa createActions(), createMenus(), createToolBars(), createStatusBar(), createLayout() and read_settings()
     */
    MainWindowImpl();
    //! Destructor
    /*!
      It saves the current window position and size that will be restored
      on the next application startup.

      \sa save_settings()
     */
    ~MainWindowImpl();
protected:
    //! Event handler override for key press events
    /*!
      This event handler captures the key press events for quick tag key combinations.

      \param event a pointer to a QKeyEvent
     */
    void keyPressEvent(QKeyEvent *event);
private slots:
    void open();
    void save();
    void about();
    void geotag();
    void preferences();
    void on_photoview_selection_changed(const QItemSelection &selected,
                                        const QItemSelection &deselected);
    void on_photoview_delete_pressed();
    void on_photoview_doubleclick(const QModelIndex &index);
    void on_add_tag_clicked();
    void on_add_button_clicked();
    void on_remove_button_clicked();
    void on_tag_list_focus_in();
    void on_tag_pool_focus_in();
    void on_caption_changed();
    void toggle_lens_data_group(bool visible);
    void set_lens_data();
private:
    void createActions();
    void createMenus();
    void createToolBars();
    void createStatusBar();
    void createLayout();
    void loadFile(const QString &fileName);
    QString strippedName(const QString &fullFileName);
    void handle_add_tag(const QString &new_tag);
    void read_settings();
    void save_settings();
    QString select_waypoint_file();
    
    QString curFile;
    
    QMenu *fileMenu;
    QMenu *helpMenu;
    QToolBar *toolBar;
    QAction *openAct;
    QAction *saveAct;
    QAction *geotagAct;
    QAction *exitAct;
    QAction *aboutAct;
    QAction *preferencesAct;
    
    QGroupBox *captionGroup;
    QVBoxLayout *captionGroupLayout;
    CaptionEdit *caption_entry;
    QGroupBox *tagListGroup;
    TagList *tag_list;
    QLineEdit *add_tag_entry;
    QPushButton *add_tag_button;
    QGroupBox *tagPoolGroup;
    TagList *tag_pool;
    QPushButton *add_button;
    QPushButton *remove_button;
    // Lens widgets
    QGroupBox *lens_data_group;
    QCheckBox *lens_cbox;
    QComboBox *lens_combo;
    QCheckBox *max_aperture_cbox;
    QDoubleSpinBox *max_aperture_sbox;
    QCheckBox *fnumber_cbox;
    QDoubleSpinBox *fnumber_sbox;
    QCheckBox *focal_cbox;
    QDoubleSpinBox *focal_sbox;
    //
    PhotoView *photoview;
    QHBoxLayout *hbox;
    QList<SHORTCUT> shortcuts;
};
#endif




